<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     * 订单状态流转日志
     * @return void
     */
    public function up()
    {
        Schema::create('order_status_logs', function (Blueprint $table) {
            $table->id();
            $table->uuid('user_id')->comment('用户id');
            $table->string('order_sn')->comment('子单号');
            $table->unsignedInteger('order_state')->comment('订单状态');
            $table->string('order_state_desc')->comment('订单状态流转描述');
            $table->timestamps();
            $table->unique(['order_sn', 'order_state'], 'unique_ordersn_state');
            $table->index(['order_sn', 'user_id'], 'idx_order_user');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_status_logs');
    }
};
